package com.elinkway.infinitemovies.async;

import android.content.Context;
import android.os.Bundle;

import com.elinkway.infinitemovies.bean.LiveInfos;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.LiveInfoParser;
import com.lvideo.http.bean.LVideoDataHull;

/**
 * 不带参数请求直播数据
 */
public class RequestLiveInfoTask extends MoviesHttpAsyncTask<LiveInfos> {

    private Bundle mParams = new Bundle();

    public RequestLiveInfoTask(Context context) {
        super(context);
    }

    private RequestResultListener<LiveInfos> mListener;

    @Override
    public LVideoDataHull<LiveInfos> doInBackground() {
        // 请求直播数据（WS||CCTV）
        return MoviesHttpApi.requestLiveChannelInfo(new LiveInfoParser(), mParams);
    }

    @Override
    public void onPostExecute(int updateId, LiveInfos result) {
        if (mListener != null) {
            mListener.onRequestSuccess(updateId, result);
        }
    }

    @Override
    public void netNull() {
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void netErr(int updateId, String errMsg) {
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    @Override
    public void dataNull(int updateId, String errMsg) {
        if (null != mListener) {
            mListener.onRequestFailed();
        }
    }

    public void setmListener(RequestResultListener<LiveInfos> mListener) {
        this.mListener = mListener;
    }

    public void setmParams(Bundle mParams) {
        this.mParams = mParams;
    }

}
